<?php
include_once(realpath(dirname(__FILE__))."/../global.php");
class sms_plugin_system{
	/**
	 * 
	 *
	 * @param Controller $controller
	 */
	public static function send($controller){
		if(!$controller->ret['result']) return;
//		$url = "http://".$_SERVER['SERVER_NAME']."/?_app=sms&_controller=system&_action=send";
		$a = &$_SERVER['LOCALE']['apps'][$controller->app];
//		$params = array(
//			'reciever'=>$controller->ret['data']['username'],
//			'reciever_id'=>'',
//			'content'=>eval_template(
//				$a[1]['message'][$controller->ret['data']['type']],
//				$controller->ret['data']
//			),
//			'sender_name'=>'[:'.($controller->app=='friends'?($controller->app."|".$controller->ret['data']['type']):$controller->app).':]',
//			'target'=>serialize($controller->ret['data']),
//			'time'=>time()
//		);
//		$params['checksum'] = call_user_func_array(array('sms_util_verifier', 'systemChecksum'), $params);
//		$content = http_request($url, $params);
		
		$content = sms_util_system::send(
			$controller->ret['data']['username'],
			'',
			eval_template(
				$a[1]['message'][$controller->ret['data']['type']],
				$controller->ret['data']
			),
			$controller->app=='friends'?($controller->app."|".$controller->ret['data']['type']):$controller->app,
			$controller->ret['data'],
			$_SERVER['REQUEST_TIME'],
			'',
			''
		);
	}
}